//
//  pipeline.hpp
//  yuzon
//
//  Created by Alvin on 2023/3/29.
//

#pragma once

#include <opencv2/opencv.hpp>
#include "common.hpp"
#include "human_detector.hpp"
#include "keypoint_detector.hpp"
#include "scorer.hpp"
#include "smoother.hpp"

class Pipeline {
public:
  explicit Pipeline(const std::string &model_detection_path,
                    const std::string &label_list_path,
                    const std::string &model_keypoint_path,
                    const std::string &angle_list_path);
  int Process(cv::Mat &image, int frame);
  void Reset();
  
  void SetDrawBbox(bool draw_bbox);
  void SetDrawPose(bool draw_pose);
  void SetBboxLineThickness(int bbox_line_thickness);
  void SetPoseKeypointNum(int pose_keypoint_num);
  void SetPoseCircleRadius(int pose_circle_radius);
  void SetPoseLineThickness(int pose_line_thickness);
  
  int GetScore();
  int GetAverageScore();
  std::vector<float> GetKeypoints();
  std::vector<float> GetTimes();
  cv::Mat GetAnnotationImage();
  std::vector<std::vector<int>> GetFrameScores();
  
private:
  bool draw_bbox_;
  bool draw_pose_;
  int bbox_line_thickness_;
  int pose_keypoint_num_;
  int pose_circle_radius_;
  int pose_line_thickness_;
  int state_;
  
  std::shared_ptr<HumanDetector> human_detector_;
  std::shared_ptr<KeypointDetector> keypoint_detector_;
  std::shared_ptr<Scorer> scorer_;
  std::shared_ptr<Smoother> smoother_;
  
  HumanResults human_results_;
  KeypointResults keypoint_results_;
  std::vector<float> elapsed_times_;
  cv::Mat annotation_image_;
  std::vector<std::vector<int>> frame_scores_;
};
